home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 5 / MacMania 5.toast / / Tools&Utilities / Plotfoil 3.2 / lib.h < prev    next >
Text File  |  1996-09-18  |  774b  |  41 lines

  1.  
  2. #define in(c, s) strchr(s, c)
  3.  
  4. /*
  5.  * useful macros
  6.  */
  7. #define streq(a, b)   (strcmp((a),(b)) == 0)
  8. #ifndef min
  9. #define min(a,b) (((a) < (b))?(a):(b))
  10. #endif
  11. #ifndef max
  12. #define max(a,b) (((a) > (b))?(a):(b))
  13. #endif
  14.  
  15. /* Stupid Turbo-C has a broken abs */
  16. #ifdef MSDOS
  17. #ifdef abs
  18. #undef abs
  19. #endif
  20. #endif
  21.  
  22. #ifndef abs
  23. #define abs(a) (((a) < 0)? -(a) : (a))
  24. #endif
  25.  
  26. /*
  27.  * To compare two slopes without division: is ay/ax > by/bx?  Multiply both
  28.  * sides by ax.bx. Now if ax.bx is positive we compare ay.bx > by.ax;
  29.  * otherwise switch the sense. This is xor.
  30.  */
  31. #define m_gt(a, b) ( ((a).x*(b).x < 0) ^ ((a).y*(b).x > (b).y*(a).x) )
  32.  
  33. #ifdef MSDOS
  34. #define OPTIONCHARS "-/"
  35. #else
  36. #define OPTIONCHARS "-"
  37. #endif
  38. #define optionchar(c) in(c, OPTIONCHARS)
  39.  
  40. #define EPSILON 1.0e-6
  41.